#include "clockform.h"
#include "ui_clockform.h"
#include <QPainter>

clockform::clockform(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::clockform)
{
    ui->setupUi(this);

    setCurrentClock(0);

}

clockform::~clockform()
{
    delete ui;
}

#define POS_STEPS 13
const unsigned int posTbl[POS_STEPS][4] ={
    {100,100,45,128},
    {100,100,40,108},
    {100,100,37,87},
    {100,100,45,65},
    {100,100,57,49},
    {100,100,78,37},
    {100,100,100,35},
    {100,100,122,38},
    {100,100,142,50},
    {100,100,155,67},
    {100,100,162,88},
    {100,100,162,110},
    {100,100,154,130}
};
void clockform::setCurrentClock(int clock){
    if(clock>=0 && clock<POS_STEPS){
        x_start = posTbl[clock][0];
        y_start = posTbl[clock][1];
        x_end = posTbl[clock][2];
        y_end = posTbl[clock][3];
    }else{
        x_start = 100;
        y_start = 100;
        x_end = 130;
        y_end = 100;
    }

        update();
}

void clockform::paintEvent(QPaintEvent *event){
    //ui-> ->setStyleSheet(QString("background-image: url(:/new/prefix1/ledon.png);"));
    QPainter painter(this);
    painter.setPen(QPen(Qt::red, 5));
    painter.drawLine(x_start,y_start,x_end,y_end);
 /*   painter.setPen(Qt::red);
    painter.drawRect(10, 10, 100, 100);
    painter.setPen(QPen(Qt::green, 5));
    painter.setBrush(Qt::blue);
    painter.drawEllipse(50, 150, 200, 200);*/
}
